// Copyright (c) 2005  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of cgal-python; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with cgal-python.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Id: Py_Direction_2.cpp 167 2007-11-02 15:36:54Z spion $
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal-python/trunk/cgal-python/bindings/Kernel/Py_Direction_2.cpp $
//
// Author(s)     : Naceur Meskini
//=========================================================================
//
#include <CGAL/basic.h>
#include <include/Kernels.h>

#include <boost/python.hpp>
#include <boost/cstdint.hpp>

const char* Direction_2_doc[]=
{
"An object of the class Direction_2 is a vector in the two-dimensional vector space RxR where we forget about its length.\nThey can be viewed as unit vectors, although there is no normalization internally, since this is error prone.\nDirections are used whenever the length of a vector does not matter.\n They also characterize a set of parallel oriented lines that have the same orientations.\nFor example, you can ask for the direction orthogonal to an oriented plane, or the direction of an oriented line.\nFurther, they can be used to indicate angles. The slope of a direction is dy()/dx().\n\
For more details see a C++ doc:\n\
http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Kernel_23_ref/Class_Direction_2.html",
"d = Direction_2(Vector_2 v)\nintroduces the direction d of vector v.\n"\
"d = Direction_2(Line_2 l)\nintroduces the direction d of line l.\n"\
"d = Direction_2(Ray_2 r)\nintroduces the direction d of Ray_2 r.\n"\
"d = Direction_2(Segment_2 s)\nintroduces the direction d of Segment_2 s.\n"\
"d = Direction_2(x,y)\nintroduces a direction d passing through the origin and the point with Cartesian coordinates (x, y)\n",
"d.counterclockwise_in_between(d1,d2) ->bool\nreturns true, iff d is not equal to d1, and while rotating counterclockwise starting at d1,\nd is reached strictly before d2 is reached. Note that true is returned if d1 == d2,\nunless also d == d1.\n",
"dx(self) -> returns delta(0).\n",
"dy(self) -> returns delta(1).\n",
"delta(self,i) -> returns values, such that d== Direction_2(delta(0),delta(1)).\nPrecondition: 0 <= i <= 1.\n",
"vector(self) -> Vector_2\nreturns a vector that has the same direction as d.\n",
"transform(self,Aff_transformation_2 t) -> Direction_2\nreturns the direction obtained by applying t on d."
};

template<class Direction_2>
boost::python::str py_repr_Direction_2(const Direction_2& d )
{
	using namespace boost::python;
	return str("Direction_2("+ str(d.dx()) +","+ str(d.dy()) +")" );
}


template<class kernel>
void Py_Direction_2()
{
	typedef typename kernel::Point_2 					Point_2;
	typedef typename kernel::Segment_2 					Segment_2;
 	typedef typename kernel::Vector_2 					Vector_2;
 	typedef typename kernel::Direction_2 					Direction_2;
 	typedef typename kernel::Line_2 					Line_2;
  	typedef typename kernel::Ray_2 					        Ray_2;
 	typedef typename kernel::Triangle_2 					Triangle_2;
	typedef typename kernel::Iso_rectangle_2 				Iso_rectangle_2;
	typedef typename kernel::Circle_2 				      	Circle_2;
	typedef typename kernel::Aff_transformation_2 				Aff_transformation_2;
	typedef typename kernel::FT 						FT;
	typedef typename kernel::RT						RT;

        using namespace boost::python;

        class_< Direction_2  >("Direction_2", Direction_2_doc[0], init<>())
        .def(init< const Direction_2& >(Direction_2_doc[1]))
        .def(init< const Vector_2& >())
        .def(init< const Line_2& >())
        .def(init< const Ray_2& >())
        .def(init< const Segment_2& >())
        .def(init< const FT&, const FT& >())
        .def(init< const double&, const double& >())

        .def("counterclockwise_in_between", &Direction_2::counterclockwise_in_between, Direction_2_doc[2])
        .def("perpendicular", &Direction_2::perpendicular)
#if CGAL_VERSION_NR < 1030301000
        .def("dx", &Direction_2::dx, by_cref(), Direction_2_doc[3])
        .def("dy", &Direction_2::dy, by_cref(), Direction_2_doc[4])
        .def("delta", &Direction_2::delta, by_cref(), Direction_2_doc[5])
#else
        .def("dx", &Direction_2::dx, typename Value_or_cref<typename kernel::Compute_dx_2, Direction_2 > ::type(), Direction_2_doc[3])
        .def("dy", &Direction_2::dy, typename Value_or_cref<typename kernel::Compute_dy_2, Direction_2 > ::type(), Direction_2_doc[4])
        .def("delta", &Direction_2::delta, typename Value_or_cref<typename kernel::Compute_dx_2, Direction_2 > ::type(), Direction_2_doc[5])
#endif
        .def("vector", &Direction_2::vector, Direction_2_doc[6])
	.def("transform", &Direction_2::transform, Direction_2_doc[7])
 	.def("__repr__", &py_repr_Direction_2<Direction_2>)
        .def( self < self )
        .def( self > self )
        .def( self >= self )
        .def( self <= self )
        .def( -self )
        .def( self == self )
        .def( self != self )
    ;
}


void export_Direction_2()
{
	Py_Direction_2<K>();
}
